home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- //////////////////////////////////////////////////////////////////////
- // Cockpit.c++ - implementation of the cockpit class
- //
- //
- // XXX Really should split this into static and dynamics portions
- // of the dash.
- //////////////////////////////////////////////////////////////////////
-
-
- #include "Cockpit.h"
- #include "Car.h"
- #include "Engine.h"
- #include "Dynamics.h"
- #include "Render.h"
- #include "Driver.h"
- #include "Icon.h"
- #include "Timer.h"
- #include "Indicators.h"
-
- Cockpit::Cockpit(Car *c)
- {
- _car = c;
-
- _gas = _brakes = _clutch = _steering = 0.0;
-
- // XXX read this stuff from a file
- _steering_pos.setValue(7.8,-.7,0.0);
-
- _tach_pos.setValue(_steering_pos[0] - 2.2, 3.0, 0.0);
- _tach_size = 2.0;
-
- _speedo_pos.setValue(_steering_pos[0] + 2.2, 3.0, 0.0);
- _speedo_size = 2.0;
-
- _gas_pos.setValue(17.5,3.0,0.0);
- _gas_size = 1.5;
-
- _temp_pos.setValue(19.75,3.0,0.0);
- _temp_size = 1.5;
-
- _oil_pos.setValue(17.5,.75,0.0);
- _oil_size = 1.5;
-
- _fps_pos.setValue(19.75,.75,0.0);
- _fps_size = 1.5;
-
- _gear_pos.setValue(15.0,_oil_pos[1], 0.0);
- _gear_width = .5;
- _gear_height = _gas_pos[1] - _oil_pos[1] + _gas_size + .1;
-
- _timer_pos.setValue(20.5,.6,0.0);
- _timer_width = 2.5;
- }
-
-
- Cockpit::~Cockpit()
- {
- }
-
-
- // draws the static portions of the cockpit
- void Cockpit::draw_cockpit(int window_width)
- {
- ortho(0.0,25.0,0.0,6.5,-10.0,10.0);
- _world_per_pixel = 25.0/(float)window_width;
-
- Boolean last_zbuffer = getzbuffer();
- Boolean last_backface = getbackface();
- long last_shademodel = getsm();
-
- cpack(0);
- clear();
-
- lmbind(LMODEL,1);
- lmbind(LIGHT0,SUN);
- shademodel(GOURAUD);
- zbuffer(FALSE);
- backface(TRUE);
-
- draw_dash();
- draw_steering_wheel();
- draw_gages(_world_per_pixel);
- draw_icons();
-
- lmbind(LMODEL,0);
- lmbind(LIGHT0,0);
- shademodel(last_shademodel);
- zbuffer(last_zbuffer);
- backface(last_backface);
-
- draw_indicators(TRUE);
- }
-
-
- // called when the window is resized to clear the overlay crap
- void Cockpit::clear_indicators() const
- {
- drawmode(PUPDRAW);
-
- color(CLEAR);
- clear();
-
- drawmode(NORMALDRAW);
- }
-
-
- void Cockpit::draw_indicators(Boolean redraw) const
- {
- ortho2(0.0,25.0,0.0,6.5);
-
- Boolean last_zbuffer = getzbuffer();
- Boolean last_backface = getbackface();
- long last_shademodel = getsm();
-
- // sync up (as much as posiible) so overlay drawing happens
- // during vertical retrace
- // XXX double buffer overlays, if possible
- gsync();
-
- drawmode(PUPDRAW);
- zbuffer(FALSE);
- backface(FALSE);
- shademodel(FLAT);
-
- if (redraw)
- {
- color(CLEAR);
- clear();
- }
-
- // draw back to front
- draw_needles(redraw); // temp, gas, etc
- draw_overlapping_needles(redraw); // speedo, tach and steering spokes
- draw_messages(redraw);
- draw_times(redraw,_world_per_pixel);
-
- drawmode(NORMALDRAW);
- zbuffer(last_zbuffer);
- backface(last_backface);
- shademodel(last_shademodel);
- }
-
-
- void Cockpit::draw_timer(float width, float world_per_pixel) const
- {
- fmfonthandle font1 = fmfindfont("Hlv");
- float pnt_size = (width/world_per_pixel)/8.0;
- fmfonthandle font = fmscalefont(font1, pnt_size);
- fmsetfont(font);
-
- cpack(ORANGE);
-
- cmov2(0.0,2.6);
- fmprstr("This Lap");
-
- cmov2(0.0,1.6);
- fmprstr("Last Lap");
-
- cmov2(0.0,.6);
- fmprstr("Best Lap");
-
- cpack(0);
- sboxf(0.0,0.0,width,0.5);
- sboxf(0.0,1.0,width,1.5);
- sboxf(0.0,2.0,width,2.5);
- }
-
-
- void Cockpit::draw_times(Boolean redraw, float world_per_pixel) const
- {
- static fmfonthandle font1, font;
- static float last_world_per_pixel = -1.0;
-
- if (world_per_pixel != last_world_per_pixel)
- {
- font1 = fmfindfont("HlvB");
- font = fmscalefont(font1, .45/world_per_pixel);
-
- last_world_per_pixel = world_per_pixel;
- }
-
- fmsetfont(font);
-
- char *buf;
-
- if (_car->get_driver()->get_timer()->get_this_lap(buf) || redraw)
- {
- color(CLEAR);
- sboxf(_timer_pos[0]-.2,_timer_pos[1]+2.0,
- _timer_pos[0]+_timer_width+.2,_timer_pos[1]+2.5);
- color(GREY2);
- cmov2(_timer_pos[0],_timer_pos[1]+2.0);
- fmprstr(buf);
- }
-
- if (_car->get_driver()->get_timer()->get_last_lap(buf) || redraw)
- {
- color(CLEAR);
- sboxf(_timer_pos[0]-.2,_timer_pos[1]+1.0,
- _timer_pos[0]+_timer_width+.2,_timer_pos[1]+1.5);
- color(GREY2);
- cmov2(_timer_pos[0],_timer_pos[1]+1.0);
- fmprstr(buf);
- }
-
- if (_car->get_driver()->get_timer()->get_best_lap(buf) || redraw)
- {
- color(CLEAR);
- sboxf(_timer_pos[0]-.2,_timer_pos[1],
- _timer_pos[0]+_timer_width+.2,_timer_pos[1]+0.5);
- color(GREY2);
- cmov2(_timer_pos[0],_timer_pos[1]);
- fmprstr(buf);
- }
- }
-
-
-
- // XXX really need an indicator class that handles all this
- void Cockpit::draw_needles(Boolean redraw) const
- {
- // gas
- pushmatrix();
- translate(_gas_pos[0], _gas_pos[1], _gas_pos[2]);
-
- static float last_gas = -1.0;
- float gas = (_car->get_engine()->get_gas());
- if (redraw || (gas != last_gas))
- {
- static float last_gas_angle = 0.0;
- pushmatrix();
- rotate((short)last_gas_angle,'z');
- scale(_gas_size,1.0,1.0);
- draw_needle(FALSE);
- popmatrix();
-
- float angle = - 900.0 * gas / _car->get_engine()->get_max_gas();
- rotate((short)angle,'z');
- scale(_gas_size,1.0,1.0);
- draw_needle(TRUE);
-
- last_gas = gas;
- last_gas_angle = angle;
- }
- popmatrix();
-
- // temp
- pushmatrix();
- translate(_temp_pos[0], _temp_pos[1], _temp_pos[2]);
-
- static float last_temp = -1.0;
- float temp = (_car->get_engine()->get_temp());
- if (redraw || (temp != last_temp))
- {
- static float last_temp_angle = 0.0;
- pushmatrix();
- rotate((short)last_temp_angle,'z');
- scale(_temp_size,1.0,1.0);
- draw_needle(FALSE);
- popmatrix();
-
- float angle = - 900.0 * temp / _car->get_engine()->get_max_temp();
- rotate((short)angle,'z');
- scale(_temp_size,1.0,1.0);
- draw_needle(TRUE);
-
- last_temp = temp;
- last_temp_angle = angle;
- }
- popmatrix();
-
- // oil
- pushmatrix();
- translate(_oil_pos[0], _oil_pos[1], _oil_pos[2]);
-
- static float last_oil = -1.0;
- float oil = (_car->get_engine()->get_oil());
- if (redraw || (oil != last_oil))
- {
- static float last_oil_angle = 0.0;
- pushmatrix();
- rotate((short)last_oil_angle,'z');
- scale(_oil_size,1.0,1.0);
- draw_needle(FALSE);
- popmatrix();
-
- float angle = - 900.0 * oil / _car->get_engine()->get_max_oil();
- rotate((short)angle,'z');
- scale(_oil_size,1.0,1.0);
- draw_needle(TRUE);
-
- last_oil = oil;
- last_oil_angle = angle;
- }
- popmatrix();
-
-
- // fps
- pushmatrix();
- translate(_fps_pos[0], _fps_pos[1], _fps_pos[2]);
-
- static float last_fps = -1.0;
- float fps = (_car->get_driver()->get_fps());
- if (redraw || (fps != last_fps))
- {
- static float last_fps_angle = 0.0;
- pushmatrix();
- rotate((short)last_fps_angle,'z');
- scale(_fps_size,1.0,1.0);
- draw_needle(FALSE);
- popmatrix();
-
- float angle = - 900.0 * fps / _car->get_driver()->get_max_fps();
- rotate((short)angle,'z');
- scale(_fps_size,1.0,1.0);
- draw_needle(TRUE);
-
- last_fps = fps;
- last_fps_angle = angle;
- }
- popmatrix();
-
-
-
- // gear indicator
- static int last_gear = -999;
- int gear = (_car->get_engine()->get_gear());
- if (redraw || (last_gear != gear))
- {
- float rect_size = 3.0*_gear_width/4.0;
-
- pushmatrix();
- translate(_gear_pos[0], _gear_pos[1], _gear_pos[2]);
- translate(_gear_width/2.0, _gear_height/2.0, 0.0);
- scale(_gear_height/6.0,_gear_height/6.0,_gear_height/6.0);
- pushmatrix();
- translate(0.0,(float)last_gear-2.0,0.0);
- color(CLEAR);
- rect(-rect_size,-rect_size,rect_size,rect_size);
- popmatrix();
- translate(0.0,(float)gear-2.0,0.0);
- color(GREY2);
- rect(-rect_size,-rect_size,rect_size,rect_size);
- popmatrix();
- }
- last_gear = gear;
- }
-
-
- void Cockpit::draw_tachometer(float diam, float world_per_pixel) const
- {
- // draw red zone
-
- static float a[2], b[2];
- a[0] = b[0] = 0.0;
- a[1] = - diam;
- b[1] = - .9*diam;
-
- float angle =
- 270.0*(float)(_car->get_engine()->get_max_rpm() -
- _car->get_engine()->get_redline())/(float)_car->get_engine()->get_max_rpm();
-
- cpack(MED_RED);
- sweep(a,b,angle);
-
-
- draw_dial(
- diam, world_per_pixel,
- 180.0, -90.0,
- .95, .9,
- .75,
- 0, _car->get_engine()->get_max_rpm(),
- 200,
- 1.0/1000.0,
- 5,
- 1);
-
- lmbind(LMODEL,1);
- lmbind(LIGHT0,DOME_LIGHT);
- lmbind(MATERIAL, GREY_PLASTIC);
-
- settorus(0.05, 1.025*diam);
- ftorus();
-
- lmbind(LMODEL,0);
- lmbind(LIGHT0,0);
- lmbind(MATERIAL, 0);
- }
-
-
- void Cockpit::draw_speedometer(float diam, float world_per_pixel) const
- {
- draw_dial(diam, world_per_pixel,
- 180.0, -90.0,
- .95, .9,
- .75,
- 0, _car->get_engine()->get_max_speed(),
- 5,
- 1.0,
- 2,
- 2);
-
-
- lmbind(LMODEL,1);
- lmbind(LIGHT0,DOME_LIGHT);
- lmbind(MATERIAL, GREY_PLASTIC);
-
- settorus(0.05, 1.025*diam);
- ftorus();
-
- lmbind(LMODEL,0);
- lmbind(LIGHT0,0);
- lmbind(MATERIAL, 0);
- }
-
-
- void Cockpit::draw_gas(float diam, float world_per_pixel) const
- {
- draw_dial(
- diam, world_per_pixel,
- 180.0, 90.0,
- .95, .9,
- .75,
- 0, (int) _car->get_engine()->get_max_gas(),
- 2,
- 1.0,
- 2,
- 1);
-
- }
-
-
- void Cockpit::draw_temp(float diam, float world_per_pixel) const
- {
- int max = (int)_car->get_engine()->get_max_temp();
-
- draw_dial(
- diam, world_per_pixel,
- 180.0, 90.0,
- .95, .9,
- .75,
- 0, max,
- max/4,
- 1.0,
- 2,
- 1);
- }
-
-
- void Cockpit::draw_oil(float diam, float world_per_pixel) const
- {
- int max = (int)_car->get_engine()->get_max_oil();
-
- draw_dial(
- diam, world_per_pixel,
- 180.0, 90.0,
- .95, .9,
- .75,
- 0, max,
- max/4,
- 1.0,
- 2,
- 1);
- }
-
-
- void Cockpit::draw_fps(float diam, float world_per_pixel) const
- {
- int max = (int)_car->get_driver()->get_max_fps();
-
- draw_dial(
- diam, world_per_pixel,
- 180.0, 90.0,
- .95, .9,
- .75,
- 0, max,
- max/6,
- 1.0,
- 2,
- 1);
- }
-
-
- // draws the string at 0.0,0.0
- void Cockpit::center_string(
- fmfonthandle font, float world_per_pixel, char *s) const
- {
- fmfontinfo font_info;
- fmgetfontinfo(font, &font_info);
-
- long pixels_high = font_info.height;
- long pixels_wide = fmgetstrwidth(font,s);
-
- float world_high = (float)pixels_high*world_per_pixel;
- float world_wide = (float)pixels_wide*world_per_pixel;
-
- cmov2(-world_wide/2.0, -world_high/2.0);
- fmsetfont(font);
- fmprstr(s);
- }
-
-
- void Cockpit::draw_gear(float width, float height, float world_per_pixel) const
- {
- fmfonthandle font1 = fmfindfont("Hlv");
- float pnt_size = (width/world_per_pixel)/2.0;
- fmfonthandle font = fmscalefont(font1, pnt_size);
-
- pushmatrix();
- translate(width/2.0,height/2.0,0.0);
- scale(height/6.0,height/6.0,height/6.0);
-
- cpack(ORANGE);
- pushmatrix();
- translate(0.0,3.0,0.0);
- center_string(font,world_per_pixel,"5");
- translate(0.0,-1.0,0.0);
- center_string(font,world_per_pixel,"4");
- translate(0.0,-1.0,0.0);
- center_string(font,world_per_pixel,"3");
- translate(0.0,-1.0,0.0);
- center_string(font,world_per_pixel,"2");
- translate(0.0,-1.0,0.0);
- center_string(font,world_per_pixel,"1");
- translate(0.0,-1.0,0.0);
- center_string(font,world_per_pixel,"N");
- translate(0.0,-1.0,0.0);
- center_string(font,world_per_pixel,"R");
- popmatrix();
-
- popmatrix();
- }
-
-
- void Cockpit::draw_gages(float world_per_pixel) const
- {
- // tachometer
- pushmatrix();
- translate(_tach_pos[0], _tach_pos[1], _tach_pos[2]);
- draw_tachometer(_tach_size, world_per_pixel);
- cmov2(-_tach_size/3.0,-_tach_size/5.0);
- cpack(ORANGE);
- fmprstr("x1000 / min");
- popmatrix();
-
- // speedometer
- pushmatrix();
- translate(_speedo_pos[0], _speedo_pos[1], _speedo_pos[2]);
- draw_speedometer(_tach_size, world_per_pixel);
- cmov2(-_speedo_size/8.0,-_speedo_size/5.0);
- cpack(ORANGE);
- fmprstr("mph");
- popmatrix();
-
- pushmatrix();
- translate(_gas_pos[0], _gas_pos[1], _gas_pos[2]);
- draw_gas(_gas_size, world_per_pixel);
- cmov2(-_gas_size/2.0,-_gas_size/5.0);
- cpack(ORANGE);
- fmprstr("gal");
- popmatrix();
-
- pushmatrix();
- translate(_temp_pos[0], _temp_pos[1], _temp_pos[2]);
- draw_temp(_temp_size, world_per_pixel);
- cmov2(-_temp_size/2.0,-_temp_size/5.0);
- cpack(ORANGE);
- fmprstr("deg F");
- popmatrix();
-
- pushmatrix();
- translate(_oil_pos[0], _oil_pos[1], _oil_pos[2]);
- draw_oil(_oil_size, world_per_pixel);
- cmov2(-_oil_size/2.0,-_oil_size/5.0);
- cpack(ORANGE);
- fmprstr("psi");
- popmatrix();
-
- pushmatrix();
- translate(_fps_pos[0], _fps_pos[1], _fps_pos[2]);
- draw_fps(_fps_size, world_per_pixel);
- cmov2(-_fps_size/2.0,-_fps_size/5.0);
- cpack(ORANGE);
- fmprstr("fps");
- popmatrix();
-
- pushmatrix();
- translate(_gear_pos[0], _gear_pos[1], _gear_pos[2]);
- draw_gear(_gear_width,_gear_height, world_per_pixel);
- popmatrix();
-
- pushmatrix();
- translate(_timer_pos[0], _timer_pos[1], _timer_pos[2]);
- draw_timer(_timer_width, world_per_pixel);
- popmatrix();
-
- // draw a bulbous box about the gas, oil, temp and fps
- // and around the gear indicator
- lmbind(LMODEL,1);
- lmbind(LIGHT0,DOME_LIGHT);
- lmbind(MATERIAL, GREY_PLASTIC);
-
- /*
- // naah, looks icky
- bulbous_box(
- _oil_pos[0] - _oil_size - .2, _oil_pos[1] - .5,
- _temp_pos[0] + .4, _temp_pos[1] + _temp_size + .25,
- .05);
- */
-
- bulbous_box(
- _gear_pos[0] - .08, _gear_pos[1] - .3,
- _gear_pos[0] + _gear_width + .08, _gear_pos[1] + _gear_height + .3,
- .05);
-
- bulbous_box(
- _timer_pos[0] - .2, _timer_pos[1] - .2,
- _timer_pos[0] + _timer_width + .2, _timer_pos[1] + 3.1,
- .05);
-
- lmbind(LMODEL,0);
- lmbind(LIGHT0,0);
- lmbind(MATERIAL, 0);
-
-
- // label how you get help
- fmfonthandle font1 = fmfindfont("Hlv");
- float pnt_size = (2.0/world_per_pixel)/8.0;
- fmfonthandle font = fmscalefont(font1, pnt_size);
- fmsetfont(font);
-
- cpack(ORANGE);
- pushmatrix();
- translate(_steering_pos[0], 5.3, 0.0);
- center_string(font, world_per_pixel, "Press H for Help");
- popmatrix();
- }
-
- void Cockpit::draw_messages(Boolean redraw) const
- {
- char buf[32];
- static Boolean last_off_road_left = FALSE;
- static Boolean last_off_road_right = FALSE;
- Boolean off_road_left = (_car->get_dynamics()->get_off_road_left());
- Boolean off_road_right = (_car->get_dynamics()->get_off_road_right());
-
- if (redraw || (off_road_left != last_off_road_left))
- {
- if (off_road_left)
- color(GREY3);
- else
- color(CLEAR);
-
- sboxf(0.0,4.0,0.5,5.0);
- bgnpolygon();
- vertex(0.5,3.5);
- vertex(1.0,4.5);
- vertex(0.5,5.5);
- endpolygon();
-
- last_off_road_left = off_road_left;
- }
-
- if (redraw || (off_road_right != last_off_road_right))
- {
- if (off_road_right)
- color(GREY3);
- else
- color(CLEAR);
-
- sboxf(24.5,4.0,25.0,5.0);
- bgnpolygon();
- vertex(24.5,5.5);
- vertex(24.5,3.5);
- vertex(24.0,4.5);
- endpolygon();
-
- last_off_road_right = off_road_right;
- }
-
- }
-
-
- void Cockpit::draw_overlapping_needles(Boolean redraw) const
- {
- float angle;
-
- static float last_rpm = 0.0;
- static float last_speed = 0.0;
- static float last_steering = 0.0;
-
- float rpm = (float)_car->get_engine()->get_rpm();
- float speed = (_car->get_dynamics()->get_velocity());
-
- // don't draw if we don't have to
- if ((!redraw)&&(rpm==last_rpm)&&(speed==last_speed)&&(_steering == last_steering))
- return;
-
- // else we first clear the needles and spokes, then draw them back
- // to front
-
- // clear tachometer
- pushmatrix();
- translate(_tach_pos[0], _tach_pos[1], _tach_pos[2]);
-
- angle = - 2700 * last_rpm / (float) _car->get_engine()->get_max_rpm();
- rotate((short)angle,'z');
-
- scale(_tach_size,1.0,1.0);
- draw_needle(FALSE);
- popmatrix();
-
- // clear speedometer
- pushmatrix();
- translate(_speedo_pos[0], _speedo_pos[1], _speedo_pos[2]);
-
- angle = - 2700 * last_speed / (float) _car->get_engine()->get_max_speed();
- rotate((short)angle,'z');
-
- scale(_speedo_size,1.0,1.0);
- draw_needle(FALSE);
- popmatrix();
-
- // clear the steering spokes
- draw_steering_spokes(FALSE,last_steering);
-
- // draw tachometer
- pushmatrix();
- translate(_tach_pos[0], _tach_pos[1], _tach_pos[2]);
-
- angle = - 2700 * rpm / (float) _car->get_engine()->get_max_rpm();
- rotate((short)angle,'z');
-
- scale(_tach_size,1.0,1.0);
- draw_needle(TRUE);
- popmatrix();
-
- // draw speedometer
- pushmatrix();
- translate(_speedo_pos[0], _speedo_pos[1], _speedo_pos[2]);
-
- angle = - 2700 * speed / (float) _car->get_engine()->get_max_speed();
- rotate((short)angle,'z');
-
- scale(_speedo_size,1.0,1.0);
- draw_needle(TRUE);
- popmatrix();
-
- // draw the steering spokes
- draw_steering_spokes(TRUE,_steering);
-
- last_rpm = rpm;
- last_speed = speed;
- last_steering = _steering;
- }
-
-
- void Cockpit::draw_steering_wheel() const
- {
- pushmatrix();
-
- translate(_steering_pos[0], _steering_pos[1], _steering_pos[2]);
-
- lmbind(LMODEL,1);
- lmbind(LIGHT0,DOME_LIGHT);
- lmbind(MATERIAL, GREY_PLASTIC);
- settorus(0.3, 6.75);
- ftorus();
-
- lmbind(MATERIAL,0);
- lmbind(LIGHT0,0);
- lmbind(LMODEL,0);
-
- cpack(DARK_GREY);
- circf(0.0,0.0,1.4);
-
- cpack(MED_GREY);
- circf(0.0,0.0,1.35);
-
- cpack(LIGHT_GREY);
- circf(0.0,0.0,1.3);
-
- popmatrix();
- }
-
-
- void Cockpit::draw_icons() const
- {
- Boolean last_backface = getbackface();
-
- backface(FALSE);
-
- pushmatrix();
- translate(_gas_pos[0], _gas_pos[1], _gas_pos[2]);
- translate(-_gas_size,3.0*_gas_size/4.0,0.0);
- scale(.5,.5,.5);
- draw_gas_icon();
- popmatrix();
-
- pushmatrix();
- translate(_oil_pos[0], _oil_pos[1], _oil_pos[2]);
- translate(-_oil_size,4.0*_oil_size/5.0,0.0);
- scale(.5,.5,.5);
- draw_oil_icon();
- popmatrix();
-
- pushmatrix();
- translate(_temp_pos[0], _temp_pos[1], _temp_pos[2]);
- translate(-_temp_size,3.0*_temp_size/4.0,0.0);
- scale(.5,.5,.5);
- draw_temp_icon();
- popmatrix();
-
- pushmatrix();
- translate(_fps_pos[0], _fps_pos[1], _fps_pos[2]);
- translate(-_fps_size,3.0*_fps_size/4.0,0.0);
- scale(.4,.4,.4);
- draw_fps_icon();
- popmatrix();
-
- backface(last_backface);
- }
-
-
-
-
-
- void Cockpit::draw_dash() const
- {
- lmbind(LIGHT0, DOME_LIGHT);
- lmbind(LMODEL,1);
-
- // draw top rim of dash
- lmbind(MATERIAL, BLACK_PLASTIC);
- pushmatrix();
- translate(12.5,6.25,0.0);
- scale(25.0,0.5,1.0);
- rotate(900,'y');
- fcylinder();
- popmatrix();
- lmbind(MATERIAL,0);
- lmbind(LIGHT0,0);
- lmbind(LMODEL,0);
-
-
- // draw dash background
- static float v1[2] = {0.0,0.0};
- static float v2[2] = {25.0,0.0};
- static float v3[2] = {25.0,5.5};
- static float v4[2] = {0.0,5.5};
- bgnpolygon();
- cpack(DASH_GREY);
- v2f(v1); v2f(v2);
- v2f(v3); v2f(v4);
- endpolygon();
-
- // draw top strip of dash background
- static float w1[2] = {0.0,5.5};
- static float w2[2] = {25.0,5.5};
- static float w3[2] = {25.0,6.0};
- static float w4[2] = {0.0,6.0};
- cpack(0x101010);
- bgnpolygon();
- v2f(w1); v2f(w2); v2f(w3); v2f(w4);
- endpolygon();
-
- }
-
-
- void Cockpit::draw_hood(int display_mode) const
- {
- Boolean last_zbuffer = getzbuffer();
- Boolean last_backface = getbackface();
- long last_shademodel = getsm();
-
- if (display_mode == RENDER_FILLED)
- {
- lmbind(LMODEL,1);
- lmbind(LIGHT0,SUN);
- shademodel(GOURAUD);
- zbuffer(FALSE);
- backface(TRUE);
- }
-
- pushmatrix();
-
- // offset from eye position to center of hood
- translate(1.5,-2.0,-2.0);
-
- pushmatrix();
- // scale(4.5,0.1,4.0);
- scale(6.0,0.1,5.0);
- rotate(-200,'x');
- if (display_mode)
- {
- lmbind(MATERIAL, RED_METAL);
- fcylinder();
- }
- else
- {
- cpack(0xFF);
- wcylinder();
- }
- popmatrix();
-
- popmatrix();
-
- if (display_mode == RENDER_FILLED)
- {
- lmbind(MATERIAL,0);
- lmbind(LIGHT0,0);
- lmbind(LMODEL,0);
- shademodel(last_shademodel);
- zbuffer(last_zbuffer);
- backface(last_backface);
- }
-
- }
-
-
- void Cockpit::draw_steering_spokes(Boolean draw_it, float steering) const
- {
- /// draw steering spokes
- short spoke_rot = 200;
-
- pushmatrix();
-
- translate(_steering_pos[0], _steering_pos[1], _steering_pos[2]);
-
- rot(- steering*180.0/M_PI,'z');
-
- pushmatrix();
- rotate(spoke_rot,'z');
- draw_steering_spoke(draw_it);
-
- scale(-1.0,1.0,1.0);
- draw_steering_spoke(draw_it);
- popmatrix();
-
- pushmatrix();
- rotate(-spoke_rot,'z');
- draw_steering_spoke(draw_it);
-
- scale(-1.0,1.0,1.0);
- draw_steering_spoke(draw_it);
- popmatrix();
-
- popmatrix();
- }
-